package br.com.ufpr.sgp.components;

import java.io.Serializable;
import java.util.List;

import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.NoRecordsToolbar;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;

import br.com.ufpr.util.base.SortableListDataProvider;

public class ListGrid<T extends Serializable> extends DataTable<T, String> {
    private static final long serialVersionUID = 1118008219632931401L;

    public ListGrid(final String id, final List<? extends IColumn<T, String>> columns, final SortableListDataProvider<T> dataProvider,
            final int rowsPerPage) {

        super(id, columns, dataProvider, rowsPerPage);
        setOutputMarkupId(true);
        setVersioned(false);
//        addTopToolbar(new CustomAjaxFallbackHeadersToolbar<String>(this, dataProvider));
        addBottomToolbar(new NoRecordsToolbar(this));
//        addBottomToolbar(new GridNavigationToolbar(this));

    }

    @Override
    protected Item<T> newRowItem(String id, int index, IModel<T> model) {
        final Item<T> rowItem = super.newRowItem(id, index, model);
        decorateRow(rowItem, model);
        return rowItem;
    }

    protected void decorateRow(final Item<T> rowItem, final IModel<T> model) {
    }
}
